<?php
error_reporting(E_WARNING);
include_once 'action.php';
include_once '../includes/metodos.php';
connectSql();

if(!empty($_POST['cmd']) && $_POST['cmd']=='faltou'){
	$query = mysql_query("UPDATE tb_agenda SET status=2 WHERE id=".$_POST['id']);
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">location.href="index.php";</SCRIPT>';
	}
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='desmarcar'){
	$query = mysql_query("UPDATE tb_agenda SET status=3 WHERE id=".$_POST['id']);
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">location.href="index.php";</SCRIPT>';
	}
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='fim'){
	$query = mysql_query("UPDATE tb_agenda SET status=4 WHERE id=".$_POST['id']);
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">window.open=history.go(-1);</SCRIPT>';
	}
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='edit'){
	edit($_POST['id']);	
}

$query= mysql_query("SELECT * FROM tb_agenda WHERE id=".$_POST['id']);
$row = mysql_fetch_array($query);
include_once '../header.php';
?>
<body> 
<!-- Start: page-top-outer -->
<div id="page-top-outer">    
	<?php include_once '../menu.php';?>

<div id="page-heading"><h1>Agenda</h1></div>

<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="<?php echo EXTERNAL_ROOT_PORTAL;?>/css/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="<?php echo EXTERNAL_ROOT_PORTAL;?>/css/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
	<!--  start content-table-inner -->
	<div id="content-table-inner">
	
<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
		<form method="post" action="edit.php">
			<tr>
				<th valign="top">Cliente:</th>
				<td><input type="text" id="tags" class="inp-form" name="cli" value="<?php echo $row['nm_cliente'];?>" disabled="true"/></td>
			</tr>
			<tr>
				<th valign="top">Telefone:</th>
				<td><input type="text" class="inp-form" name="tel" value="<?php echo $row['telefone'];?>"/></td>
			</tr>
			<tr>
				<th valign="top">Celular:</th>
				<td><input type="text" class="inp-form" name="cel" value="<?php echo $row['celular'];?>"/></td>
			</tr>
			<input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
			<input type="hidden" name="cliente" value="<?php echo $row['nm_cliente'];?>"/>
			<input type="hidden" name="cmd" value="edit"/>
			<td valign="top">
				<td><input class="form-submit" type="submit" value=""></td>
			</td>
		</form>
 </table>
<div class="clear"></div>

</div>
<!--  end content-table-inner  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>

<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer -->

<div class="clear">&nbsp;</div>
    
<?php include_once '../footer.php';?>
</body>
</html>